package com.snl.micro.blog.common.protocol;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class ResponseResult<T> {

    private Integer code;
    private String message;
    private T data;

    public ResponseResult(Status status) {
        this.code = status.getCode();
        this.message = status.getMessage();
    }

    public ResponseResult(Status status,T data) {
        this.code = status.getCode();
        this.message = status.getMessage();
        this.data = data;
    }

    //封装一些静态方法 方便业务调用
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(Status.SUCCESS,data);
    }

    public static <T> ResponseResult<T> fail() {
        return new ResponseResult<>(Status.FAILED,null);
    }


}
